#ifndef _TEXTURED_ENTITY_H_
#define _TEXTURED_ENTITY_H_

#include <string>
#include <boost/shared_ptr.hpp>

#include "Entity.h"

#include "GLee.h"
#include <GL/glu.h>

class GLSLProgram;
class Behaviour;
class Animation;
class GLTexture;

class TexturedEntity : public Entity
{
public:
    TexturedEntity(void);
    TexturedEntity(boost::shared_ptr<Scene> scene);
    TexturedEntity(boost::shared_ptr<Scene> scene, const std::string& textureName);
    virtual ~TexturedEntity(void);

    void setTextureName(const std::string& textureName) { m_textureName = textureName; }
    void setPositionInTexture(const Vector3& position) { m_positionInTexture = position; }
    void setSizeInTexture(const Dimension& size) { m_sizeInTexture = size; }
    void updatePixelsSize(const Dimension& size);

    void attachBehaviour(Behaviour* behaviour);
    void attachAnimation(Animation* animation);
    void detachBehaviour(void);
    void detachAnimation(void);

protected:
    std::string m_textureName;
    boost::shared_ptr<GLTexture> m_texture;
    GLuint m_vertexBuffer;
    GLuint m_texCoordBuffer;
    static GLSLProgram* m_shaderProgram;
    Vector3 m_positionInTexture;
    Dimension m_sizeInTexture;
    Behaviour* m_behaviour;
    Animation* m_animation;

    bool commonInit();
    void commonPrepare(float dT);

private:
    virtual void onPrepare(float dT);
    virtual void onRender() const;
    virtual void onPostRender();
    virtual bool onInitialize();
    virtual void onShutdown();
    virtual void onDestroy(void);

};

#endif 
